from django.db import models


# 管理员表
class Admins(models.Model):
    username = models.CharField(max_length=32, unique=True, verbose_name='账号')
    password = models.CharField(max_length=65, verbose_name='密码')
    name = models.CharField(max_length=32, blank=True, verbose_name='姓名')
    tel = models.CharField(max_length=15, blank=True, verbose_name='手机号码')
    email = models.CharField(max_length=254, blank=True, verbose_name='邮箱')
    is_superuser = models.BooleanField(default=False, verbose_name='0普通，1超级管理员')
    is_active = models.BooleanField(default=False, verbose_name='0禁用，1启用')
    is_delete = models.BooleanField(default=False, verbose_name='0正常，1删除')
    date_add = models.DateTimeField(auto_now_add=True, verbose_name='账号注册时间')
    date_lock = models.DateTimeField(verbose_name='账号解锁时间')
    err_num = models.PositiveIntegerField(default=0, verbose_name='密码错误次数')
    role = models.ForeignKey(to='role.AdminRole', blank=True, null=True, on_delete=models.SET_NULL, db_constraint=False,
                             related_name='admin')
    department = models.ForeignKey(to='department.AdminDepartment', blank=True, null=True, on_delete=models.SET_NULL,
                                   db_constraint=False,
                                   related_name='admin')

    class Meta:
        db_table = 'zeus_admin'
        verbose_name = '管理员'
        verbose_name_plural = verbose_name

        def __str__(self):
            return self.username
